package com.hfjyz.payment.bean;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.hfjyz.payment.constant.Constant;

public class ConfigBean {
    private static String keystore = null;
    private static String keystorePassword = null;
    private static String caCer = null;
    private static String bankUrl = null;

    private static String driverName = null;
    private static String jdbcUrl = null;
    private static String userName = null;
    private static String password = null;

    static {
        init();
    }

    private static void init() {
        InputStream in = null;
        try {
            in = PaySearchBean.class.getResourceAsStream("/config.properties");
            Properties p = new Properties();
            p.load(in);

            keystore = p.getProperty(Constant.KEY_STORE);
            keystorePassword = p.getProperty(Constant.KEY_STORE_PASSWORD);
            caCer = p.getProperty(Constant.CA_CER);
            bankUrl = p.getProperty(Constant.BANK_URL);

            driverName = p.getProperty(Constant.DRIVER_NAME);
            jdbcUrl = p.getProperty(Constant.JDBC_URL);
            userName = p.getProperty(Constant.USER_NAME);
            password = p.getProperty(Constant.USER_PASSWORD);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (in != null)
                    in.close();
            } catch (IOException e) {
            }
        }
    }

    public static String getKeystore() {
        return keystore;
    }

    public static void setKeystore(String keystore) {
        ConfigBean.keystore = keystore;
    }

    public static String getKeystorePassword() {
        return keystorePassword;
    }

    public static void setKeystorePassword(String keystorePassword) {
        ConfigBean.keystorePassword = keystorePassword;
    }

    public static String getCaCer() {
        return caCer;
    }

    public static void setCaCer(String caCer) {
        ConfigBean.caCer = caCer;
    }

    public static String getBankUrl() {
        return bankUrl;
    }

    public static void setBankUrl(String bankUrl) {
        ConfigBean.bankUrl = bankUrl;
    }

    public static String getDriverName() {
        return driverName;
    }

    public static void setDriverName(String driverName) {
        ConfigBean.driverName = driverName;
    }

    public static String getJdbcUrl() {
        return jdbcUrl;
    }

    public static void setJdbcUrl(String jdbcUrl) {
        ConfigBean.jdbcUrl = jdbcUrl;
    }

    public static String getUserName() {
        return userName;
    }

    public static void setUserName(String userName) {
        ConfigBean.userName = userName;
    }

    public static String getPassword() {
        return password;
    }

    public static void setPassword(String password) {
        ConfigBean.password = password;
    }
}
